{include file="public/toper"/}
<style>
    .layui-unselect{width: 190px;}
    .layui-form-select dl {width:190px;}
</style>
<div class="x-body">
    <form action="" method="post" class="layui-form" id="forms">
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>会员卡名称</label>
            <div class="layui-input-inline">
                <select name="card_id" lay-filter="type">
                    {volist name ="card" id ="vo"}
                    <option value="{$vo.card_id}" selected>{$vo.name}</option>
                    {/volist}
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red"></span></label>
            <div class="layui-input-inline" id="guige" lay-filter="guig"></div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>销售单据号
            </label>
            <div class="layui-input-inline">
                <input type="number" value="" name="sales_order" min="1" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>20个字符
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>实付价格
            </label>
            <div class="layui-input-inline">
                <input type="number" value="" name="price" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>销售员</label>
            <div class="layui-input-inline">
                <select name="store_user_id">
                    {volist name ="store" id ="vo"}
                    <option value="{$vo.store_user_id}">{$vo.name}</option>
                   {/volist}
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>有效期
            </label>
            <div class="layui-input-inline">
                <input type="number" value="" name="effective" max="9" min="1" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red"></span>1-9之间，天数
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red"></span>备注
            </label>
            <div class="layui-input-inline">
                <input type="text" value="" name="note" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red"></span>255字符
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <button  class="layui-btn" lay-filter="formSubmit" lay-submit="">提交</button>
        </div>
    </form>
</div>

<script>
    layui.use(['form'], function(){
        $ = layui.jquery;
        var form = layui.form,layer = layui.layer;

        form.on('select(type)', function(data){
            $.ajax({
                type: "POST",
                data:{id:data.value},
                url:  "{:url('Offline/card')}",
                success: function(res) {
                    $('#guige').empty();
                    $("#guige").append(res);
                    form.render('select', 'guig');
                }
            });
        });

        $.ajax({
            type: "POST",
            data:{id:$("select  option:selected").val()},
            url:  "{:url('Offline/card')}",
            success: function(res) {
                $('#guige').empty();
                $("#guige").append(res);
                form.render('select', 'guig');
            }
        });

    });
</script>
{include file="public/footer"/}